# Copyright(c) 2008 Tri Tech Information Systems Inc. 
# Distributed under the Boost Software License, Version 1.0.
#     (See accompanying file ../../LICENSE_1_0.txt or copy at
#           http://www.boost.org/LICENSE_1_0.txt)
#     
def simple_test():
    """
    >>> from interface import A, B, C, Do
    >>> A(2)
    Traceback (most recent call last):
        ...
    RuntimeError: This class cannot be instantiated from Python
    >>> b = B(2, 5.0)
    >>> b
    <interface.B object at 0x...>
    >>> b.e()
    Traceback (most recent call last):
        ...
    logic_error: e called on interface.B which has no overrider
    >>> class B2(B):
    ...     def e(self):
    ...         print "here"
    >>> b = B2(2, 5.0)
    >>> b.e()
    here
    >>> c = C(12, 25, 'c')
    >>> c.a()
    'yellow'
    >>> c.b()
    'yikes'
    >>> c.e()
    >>> Do(b)
    >>> Do(c)
    """

def adoption_test():
    """
    adoptMethod allows us to move a standalone function into a class

    >>> from interface import *

    >>> b = B(3, 4.5)
    >>> b.add(11, 12)
    23

    """

def data_test():
    """
    Data is a struct containing some data member that we can play with

    >>> from interface import *
    >>> d = Data()
    >>> d.m_a
    67
    >>> d.m_a = 54
    >>> d.m_a
    54
    >>> d.m_b
    6.78...
    >>> d.m_b = 4.5
    Traceback (most recent call last):
        ...
    AttributeError: can't set attribute
    >>> Data.s_c
    12
    >>> Data.s_c = 234
    >>> Data.s_c
    234
    >>> Data.s_d
    3.45...
    >>> Data.s_d = 6.78
    Traceback (most recent call last):
        ...
    AttributeError: can't set attribute

    The following doesn't work, I have not got a 
    good reason to fix it yet

    >> d.m_e
    <interface.Data object at 0x...>
    >> d.m_e.s_c
    234
    >> d.m_e = Data()
    Traceback (most recent call last):
        ...
    AttributeError: can't set attribute

    >>> d.p_1
    Traceback (most recent call last):
        ...
    AttributeError: 'Data' object has no attribute 'p_1'

    >>> d.p_2
    Traceback (most recent call last):
        ...
    AttributeError: 'Data' object has no attribute 'p_2'

    >>> print Data.m_f
    <interface.Data object at 0x...>

    >>> Data.m_f.m_a
    67

    >>> Data.m_f = 323
    Traceback (most recent call last):
        ...
    AttributeError: can't set attribute

    """

def test_unrelated():
    """
    >>> from interface import *
    >>> class MyClass(Unrelated):
    ...     pass
    >>> y = MyClass()
    >>> x = SomeObject(y)
    """
    

if __name__ == '__main__':
    import doctest
    import sys
    sys.exit(doctest.testmod(optionflags = doctest.ELLIPSIS)[0])

